//#include "advancedConfig.h"
//#include "ui_advancedConfig.h"

// 暂时不做单孔位的

//AdvancedConfig::AdvancedConfig(int row, int col, QWidget *parent) :
//    QWidget(parent),
//    ui(new Ui::AdvancedConfig), _row(row), _col(col)
//{
//    ui->setupUi(this);

//    _posiPannel = new PosiPannel(row, col, 0);
//    _posiPannel->setNormMode(true);
//    ui->layout_posiPannel->addWidget(_posiPannel);
//    ui->layout_selectType->addSpacerItem(new QSpacerItem(20,20,QSizePolicy::Expanding));
//    ui->radioButton_FAM->setChecked(true);

//    _buttonGroup_channel = new QButtonGroup(this);
//    _buttonGroup_fixedBaseline = new QButtonGroup(this);
//    _buttonGroup_channel->addButton(ui->radioButton_FAM);
//    _buttonGroup_channel->addButton(ui->radioButton_CY5);
//    _buttonGroup_channel->addButton(ui->radioButton_ROX);
//    _buttonGroup_channel->addButton(ui->radioButton_VIC);
//    _buttonGroup_fixedBaseline->addButton(ui->radioButton_open);
//    _buttonGroup_fixedBaseline->addButton(ui->radioButton_close);

//    connect(_posiPannel, SIGNAL(sigSelectChanged(QStringList)), this, SLOT(on_selectPosiChanged(QStringList)));


//    QMap<QString, double> defaultConfig;
//    defaultConfig["FIXED_BASE_END"] = -1;
//    defaultConfig["CLIP_START"] =     5;
//    defaultConfig["SLOPE_THR"] =      2.8;
//    defaultConfig["SLOPE_THR_DOWN"] = 0.6;
//    defaultConfig["MIN_CONF"] =       0.9;
//    defaultConfig["RANGE_THR"] =      1000;
//    _states_channel["FAM"] = defaultConfig;
//    _states_channel["VIC"] = defaultConfig;
//    _states_channel["ROX"] = defaultConfig;
//    _states_channel["CY5"] = defaultConfig;

//}

//void AdvancedConfig::showEvent(QShowEvent *event){
//    _curChannel = "FAM";
//    ui->radioButton_FAM->setChecked(true);
//    if(_selectableList.size()==0){
//        qDebug() << "数据列表为空，无法高级配置";
//        return;
//    }
//    _curPosi = _selectableList[0];
//    _posiPannel->setSelectColor(QColor("#93A8FC"));
//    _posiPannel->setSelectCell(QStringList(_curPosi));
//    state2edit();
//}

//AdvancedConfig::~AdvancedConfig()
//{
//    delete ui;
//}



//void AdvancedConfig::setParamsList(QMap<QString, QMap<QString, double>> states){
//    _states = states;
//}
//void AdvancedConfig::setSelectableList(QStringList list){
//    _selectableList = list;
//    updatePannelSelectable();
//}

//void AdvancedConfig::setFittedList(QVector<QStringList> list){
//    _fittedLists = list;
//    updatePannelSelectable();
//}

//void AdvancedConfig::updatePannelSelectable(){

//    QStringList posiList = _selectableList;
//    //    foreach(QString curve, _selectableList){          // selectable细化暂时关闭
//    //        if(curve.contains(_curChannel)){
//    //            posiList.push_back(curve.split('_')[1]);
//    //        }
//    //    }
//    _posiPannel->setSelectableCell(posiList);
//    if(!posiList.contains(_curPosi)){
//        _posiPannel->setSelectCell({posiList[0]});
//        _curPosi = posiList[0];
//    }

//    if(_curChannel=="FAM"){
//        _posiPannel->setSelectColor(QColor("#93A8FC"));
//        if(_fittedLists.size() >= 1){
//            _posiPannel->setNormCell(_fittedLists[0]);
//        }
//    }else if(_curChannel=="VIC"){
//        _posiPannel->setSelectColor(QColor("#82F0AF"));
//        if(_fittedLists.size() >= 2){
//            _posiPannel->setNormCell(_fittedLists[1]);
//        }
//    }else if(_curChannel=="ROX"){
//        _posiPannel->setSelectColor(QColor("#FFC39A"));
//        if(_fittedLists.size() >= 3){
//            _posiPannel->setNormCell(_fittedLists[2]);
//        }
//    }else if(_curChannel=="CY5"){
//        _posiPannel->setSelectColor(QColor("#FF8387"));
//        if(_fittedLists.size() >= 4){
//            _posiPannel->setNormCell(_fittedLists[3]);
//        }
//    }

//}

//void AdvancedConfig::on_selectPosiChanged(QStringList str){
//    if(str.size() < 1){
//        return;
//    }
//    _curPosi = str[0];
//    emit sigSelectCurveChanged(QStringList(_curChannel+"_"+_curPosi));

//    state2edit();
//}

//void AdvancedConfig::edit2state(){

//    if(_changeMode == 0){
//        if (!_states.contains(_curChannel+"_"+_curPosi)){
//            return;
//        }
//        QMap<QString, double> res;
//        res["FIXED_BASE_END"] = ui->radioButton_open->isChecked() ? ui->lineEdit_FIXED_BASE_END->text().toDouble() : -1;
//        res["CLIP_START"] =     ui->lineEdit_CLIP_START->text().toDouble();
//        res["SLOPE_THR"] =      ui->lineEdit_SLOPE_THR->text().toDouble();
//        res["SLOPE_THR_DOWN"] = ui->lineEdit_SLOPE_THR_DOWN->text().toDouble();
//        res["MIN_CONF"] =       ui->lineEdit_MIN_CONF->text().toDouble();
//        res["RANGE_THR"] =      ui->lineEdit_RANGE_THR->text().toDouble();
//        _states[_curChannel+"_"+_curPosi] = res;
//    }else{
//        QMap<QString, double> res;
//        res["FIXED_BASE_END"] = ui->radioButton_open->isChecked() ? ui->lineEdit_FIXED_BASE_END->text().toDouble() : -1;
//        res["CLIP_START"] =     ui->lineEdit_CLIP_START->text().toDouble();
//        res["SLOPE_THR"] =      ui->lineEdit_SLOPE_THR->text().toDouble();
//        res["SLOPE_THR_DOWN"] = ui->lineEdit_SLOPE_THR_DOWN->text().toDouble();
//        res["MIN_CONF"] =       ui->lineEdit_MIN_CONF->text().toDouble();
//        res["RANGE_THR"] =      ui->lineEdit_RANGE_THR->text().toDouble();
//        _states_channel[_curChannel] = res;
//        for(auto iter = _states.begin(); iter != _states.end(); iter ++){       // 单个孔位同步
//            if(iter.key().contains(_curChannel)){
//                _states[iter.key()] = res;
//            }
//        }
//    }


//}
//void AdvancedConfig::state2edit(){
//    if(_changeMode == 0){
//        qDebug() << "设置数据" << _curChannel+"_"+_curPosi;
//        if (!_states.contains(_curChannel+"_"+_curPosi)){
//            return;
//        }
//        auto res = _states[_curChannel+"_"+_curPosi];
//        ui->radioButton_open->setChecked(res["FIXED_BASE_END"]!=-1);
//        ui->radioButton_close->setChecked(res["FIXED_BASE_END"]==-1);
//        ui->lineEdit_FIXED_BASE_END  ->setText(QString::number(res["FIXED_BASE_END"]));
//        ui->lineEdit_CLIP_START      ->setText(QString::number(res["CLIP_START"]));
//        ui->lineEdit_SLOPE_THR       ->setText(QString::number(res["SLOPE_THR"]));
//        ui->lineEdit_SLOPE_THR_DOWN  ->setText(QString::number(res["SLOPE_THR_DOWN"]));
//        ui->lineEdit_MIN_CONF        ->setText(QString::number(res["MIN_CONF"]));
//        ui->lineEdit_RANGE_THR       ->setText(QString::number(res["RANGE_THR"]));
//        updateEditorState();
//    }else{
//        auto res = _states_channel[_curChannel];
//        ui->radioButton_open->setChecked(res["FIXED_BASE_END"]!=-1);
//        ui->radioButton_close->setChecked(res["FIXED_BASE_END"]==-1);
//        ui->lineEdit_FIXED_BASE_END  ->setText(QString::number(res["FIXED_BASE_END"]));
//        ui->lineEdit_CLIP_START      ->setText(QString::number(res["CLIP_START"]));
//        ui->lineEdit_SLOPE_THR       ->setText(QString::number(res["SLOPE_THR"]));
//        ui->lineEdit_SLOPE_THR_DOWN  ->setText(QString::number(res["SLOPE_THR_DOWN"]));
//        ui->lineEdit_MIN_CONF        ->setText(QString::number(res["MIN_CONF"]));
//        ui->lineEdit_RANGE_THR       ->setText(QString::number(res["RANGE_THR"]));
//        updateEditorState();
//    }

//}

//void AdvancedConfig::on_radioButton_open_clicked(){
//    ui->lineEdit_FIXED_BASE_END->setText("20");
//    this->updateEditorState();
//}void AdvancedConfig::on_radioButton_close_clicked(){
//    ui->lineEdit_FIXED_BASE_END->setText("-1");
//    this->updateEditorState();
//}

//void AdvancedConfig::updateEditorState(){
//    if(ui->radioButton_open->isChecked()){
//        ui->lineEdit_FIXED_BASE_END ->setEnabled(true);
//        ui->lineEdit_MIN_CONF       ->setEnabled(false);
//        ui->lineEdit_RANGE_THR      ->setEnabled(false);
//        ui->lineEdit_SLOPE_THR      ->setEnabled(false);
//        ui->lineEdit_CLIP_START     ->setEnabled(false);
//        ui->lineEdit_SLOPE_THR_DOWN ->setEnabled(false);
//    }else if(ui->radioButton_close->isChecked()){
//        ui->lineEdit_FIXED_BASE_END ->setEnabled(false);
//        ui->lineEdit_MIN_CONF       ->setEnabled(true);
//        ui->lineEdit_RANGE_THR      ->setEnabled(true);
//        ui->lineEdit_SLOPE_THR      ->setEnabled(true);
//        ui->lineEdit_CLIP_START     ->setEnabled(true);
//        ui->lineEdit_SLOPE_THR_DOWN ->setEnabled(true);
//    }
//}

//void AdvancedConfig::on_radioButton_CY5_clicked(){
//    _curChannel = "CY5";
//    updatePannelSelectable();
//    if(_changeMode == 0){
//        emit sigSelectCurveChanged(QStringList(_curChannel+"_"+_curPosi));
//    }
//    state2edit();
//}void AdvancedConfig::on_radioButton_FAM_clicked(){
//    _curChannel = "FAM";
//    updatePannelSelectable();
//    if(_changeMode == 0){
//        emit sigSelectCurveChanged(QStringList(_curChannel+"_"+_curPosi));
//    }
//    state2edit();
//}void AdvancedConfig::on_radioButton_ROX_clicked(){
//    _curChannel = "ROX";
//    updatePannelSelectable();
//    if(_changeMode == 0){
//        emit sigSelectCurveChanged(QStringList(_curChannel+"_"+_curPosi));
//    }
//    state2edit();
//}void AdvancedConfig::on_radioButton_VIC_clicked(){
//    _curChannel = "VIC";
//    updatePannelSelectable();
//    if(_changeMode == 0){
//        emit sigSelectCurveChanged(QStringList(_curChannel+"_"+_curPosi));
//    }
//    state2edit();
//}

//void AdvancedConfig::on_pushButton_reanalysis_clicked()
//{
//    edit2state();
//    qDebug() << "修改孔位:" << _curChannel+"_"+_curPosi;
//    if(_changeMode==0){
//        qDebug() << "修改值:" << _states[_curChannel+"_"+_curPosi];
//        emit sigReanalysis(_curChannel+"_"+_curPosi, _states[_curChannel+"_"+_curPosi]);
//    }else{
//        qDebug() << "修改值:" << _states[_curChannel];
//        emit sigReanalysis(_curChannel, _states_channel[_curChannel]);
//    }
//}

//void AdvancedConfig::on_pushButton_setDefault_clicked(){

//    QMap<QString, double> res;
//    res["FIXED_BASE_END"] = -1;
//    res["CLIP_START"] =     5;
//    res["SLOPE_THR"] =      2.8;
//    res["SLOPE_THR_DOWN"] = 0.6;
//    res["MIN_CONF"] =       0.9;
//    res["RANGE_THR"] =      1000;

//    ui->radioButton_open->setChecked(res["FIXED_BASE_END"]!=-1);
//    ui->radioButton_close->setChecked(res["FIXED_BASE_END"]==-1);
//    ui->lineEdit_FIXED_BASE_END  ->setText(QString::number(res["FIXED_BASE_END"]));
//    ui->lineEdit_CLIP_START      ->setText(QString::number(res["CLIP_START"]));
//    ui->lineEdit_SLOPE_THR       ->setText(QString::number(res["SLOPE_THR"]));
//    ui->lineEdit_SLOPE_THR_DOWN  ->setText(QString::number(res["SLOPE_THR_DOWN"]));
//    ui->lineEdit_MIN_CONF        ->setText(QString::number(res["MIN_CONF"]));
//    ui->lineEdit_RANGE_THR       ->setText(QString::number(res["RANGE_THR"]));
//}

//void AdvancedConfig::on_pushButton_single_clicked(){
//    _changeMode = 0;
//    _posiPannel->show();
//    ui->pushButton_channel->setStyleSheet("background: #FFFFFF;\n\nborder: 1px solid #007bd8;");
//    ui->pushButton_single->setStyleSheet("background: #007bd8; color: #FFFFFF;\n\nborder: 1px solid #007bd8;");
//    state2edit();
//}

//void AdvancedConfig::on_pushButton_channel_clicked()
//{
//    _changeMode = 1;
//    _posiPannel->hide();
//    ui->pushButton_single->setStyleSheet("background: #FFFFFF;\n\nborder: 1px solid #007bd8;");
//    ui->pushButton_channel->setStyleSheet("background: #007bd8; color: #FFFFFF;\n\nborder: 1px solid #007bd8;");
//    state2edit();
//}

//void AdvancedConfig::on_pushButton_cancel_clicked()
//{
//    emit sigCancel();
//}
